
// import TableList from "@components/templates/tablelist";
import TableList from "@components/templates/customtablelist";
import { HttpBillCustomer,HttpConfirmBillCustomer } from '@/service/api/views';
import { mapState,mapGetters } from "vuex";
export default {
    mixins: [TableList],
    data() {
        return {
            // totals: 0,
            isMixin: true,
            Tools: {show: true},
            Tabs: {show: true},
            formData:{
                search:{
                    EQ_month:''
                }
            },
            Searchs: {
                show: true,
                labelWidth: 120,
            },
            Plugins: {show: true},
        }
    },
    methods: {
        ajaxRequest: HttpBillCustomer,
        interceptRequest (params) {
            if (params.search.EQ_month&&params.search.EQ_month[0]!='') {
                params.search.EQ_month = this.handleDateFormat(params.search.EQ_month,'yy-mm')+'-01'
            }
            return params
        },
        handleOperates(params="", type,batch) {
            if(batch===true){
                params=(params||this.checkedData.join(','))+'';
                if(!params.length) return this.$Message.warning('请选择至少一条数据');
            }
            switch (type) {
                case 'query': {
                    this.$emit('on-choosetabs',params)
                    // search.module = 'detail';
                    // search.formData.EQ_billId = id;
                }; break;
                case 'confirm':
                    this.operate = {
                        show: true,
                        alert: "primary",
                        params: { id: params },
                        title: "账单确认",
                        ajaxRequest: HttpConfirmBillCustomer
                    }
                break
                case 'exportQuery':
                    this.handleWebfs(process.env.VUE_APP_APIURL_SHIP + "/api/jwt/spl/bill/manage/export", 'download')
                break
                
            }
        },
    },
    computed: {
        ...mapGetters('dictionary', ['getSysAllList']),
        // 搜索下拉框展示内容
        SearchsData() {
            return  [
                {
                    label: '状态',
                    key: 'EQ_status',
                    tag: 'Select',
                    options: [
                        { label: '初始化', value: 0 },
                        { label: '已确认', value: 1 },
                    ],
                    show: true,
                },
                {
                    label: '组织',
                    key: 'EQ_organizationId',
                    tag: 'Select',
                    options: this.getSysAllList,
                    props:{
                        filterable:true,
                    },
                    show: true,
                },
                {
                    label: '月份',
                    tag: 'DatePicker',
                    key: 'EQ_month',
                    props:{
                        type:'month',
                        confirm:false,
                    },
                    show:true,
                    // hideSearchTip:true,
                },
            ]
        },
        ToolsData(){
            return [
                {
                    name: "账单确认",
                    theme: 'info',
                    operate: 'confirm',
                    batch:true,
                },
                {
                    name: "导出",
                    theme: 'success',
                    operate: 'exportQuery',
                },
            ]
        },
        // table的展示数据
        columns() {
            return [{
                title: "#",
                type: "selection",
                width: 70,
            }, {
                title: "账户组织",
                key: "organizationName",
                sortable: true,
            }, {
                title: "总金额（USD）",
                key: "totalAmout",
                sortable: true,
            }, {
                title: "账单状态",
                key: "status",
                sortable: true,
                render(h, { row }) {
                    return <span>{row.status == 0 ? '初始化' : '已确认'}</span>
                }
            }, {
                title: "月份",
                key: "month",
                sortable: true,
                render(h, { row }) {
                    return <span>{(row.month || "").substr(0, 7)}</span>
                }
            }, {
                title: "-",
                render: (h, { row }) => {
                    return <a onClick={this.handleOperates.bind(this, row.id, 'query')}>明细</a>
                }
            }]
        },
        
    },

};
